//skill prices, now allowed to evolve over time
***********ACS Data***********
use "$temp/acs_master", clear //open
drop if school==2

//restrictions and regressoin variables
gen black = (race == 2) //black dummy
gen male = (sex == 1) //sex dummy
gen hispanic = (hispan!=0) //hispanic

//hs sample
keep if year>=2008 & year<=2012
keep if educ == 6
gen exp = age - (educ+12)
drop if exp<0
keep statefip year black male hispanic educ wage_hourly perwt bpl age hours exp

//wrap up
keep if age>=25 & age<=54
compress
save "$temp/ACS_skill_price_sample", replace

***********Prep Census Data***********
use "$temp/census_master", clear
merge 1:1 serial pernum using "$data/ACS/usa_00047", nogen //family interrelationship stuff
drop if school==2

//sample restrictions
//keep if uhrswork>=36 & uhrswork<=60 //restrict sample based on labor force attachment
//keep if wkswork1>=50 //for ACS comparability

//regression variables
gen black = (race == 2) //black dummy
gen male = (sex == 1) //sex dummy
gen hispanic = (hispan!=0) //hispanic

//hs sample
keep if educ == 6
gen exp = age - (educ+12)
drop if exp<0
keep if age>=25 & age<=54
keep statefip year black male hispanic educ wage_hourly perwt bpl age hours exp

//wrap up
append using "$temp/ACS_skill_price_sample" //add on ACS sample
compress
save "$temp/skill_price_dynamics_sample", replace

****MAIN REGRESSIONS***
use "$temp/skill_price_dynamics_sample", clear
gen period = 1
replace period = 2 if year>=2008
ren statefip stfips

//log wage variable
gen l_wage = log(wage_hourly)

//regression based on strategy
reg l_wage black male hispanic c.exp##c.exp##c.exp##c.exp ib19.stfips#i.period [fweight=perwt], robust

//convert to data
levelsof stfips, clean local (fips)
clear
set obs 50
gen statefips = .
gen skill_price_p1 = .
gen skill_price_p2 = .
local counter = 0

//loop over fips and fill in skill prices
foreach fip in `fips'{
	local counter `++counter'
	
	replace statefips = `fip' in `counter'
	replace skill_price_p1 = _b[`fip'.stfips#1.period] in `counter'
	replace skill_price_p2 = _b[`fip'.stfips#2.period] in `counter'
}	

//exponentiate and save
replace skill_price_p1 = exp(skill_price_p1)
replace skill_price_p2 = exp(skill_price_p2)
ren skill_price_p1 skill_price_2000
ren skill_price_p2 skill_price_2010
save "$temp/skill_prices", replace





